import { app } from 'db://app-game/core/app';
import { ecs } from 'db://app-game/libs/ecs/ECS';
import { GameEvent } from '../../../../common/config/GameEvent';
import { smc } from '../../../singleton/SingletonModuleComp';
import { Account } from '../Account';
import { AccountModelComp } from '../model/AccountModelComp';

/** 网络模式 */
export enum NetworkMode {
  /** 离线模型 */
  Offline = 0,
  /** 网络模式 */
  Online = 1,
}

/** 请求玩家游戏数据 */
@ecs.register('AccountNetData')
export class AccountNetDataComp extends ecs.Comp {
  /** 网络模式 */
  networkMode: NetworkMode.Offline;
  reset() {
    this.networkMode = NetworkMode.Offline;
  }
}

/** 请求玩家游戏数据系统 */
@ecs.register('Account')
export class AccountNetDataSystem extends ecs.ComblockSystem implements ecs.IEntityEnterSystem {
  filter(): ecs.IMatcher {
    return ecs.allOf(AccountNetDataComp, AccountModelComp);
  }

  entityEnter(account: Account): void {
    let data;
    // 1.离线模式
    smc.storage.load();
    // 2.网络模式

    // 4.玩家登录成功事件
    app.message.dispatchEvent(GameEvent.LoginSuccess);
  }
}
